package com.mo.lib.ui.activity

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.mo.lib.ui.action.HandlerAction
import com.mo.lib.ui.activity.BaseActivity
import com.mo.lib.utils.KLog
import java.lang.reflect.InvocationTargetException
import java.lang.reflect.Method
import java.lang.reflect.ParameterizedType

/**
 * @ author：mo
 * @ data：2022/3/21:15:40
 * @ 功能：ViewDataBinding基类
 * 注意：继承此类的子类里不能再有泛型了，否则反射会出错
 */

abstract class BaseVbmActivity<VB : ViewDataBinding,VM:ViewModel>() : BaseVbActivity<VB>(){
    lateinit var viewModel: VM
    override fun initView(savedInstanceState: Bundle?) {
        super.initView(savedInstanceState)
        val superclass = javaClass.genericSuperclass
        val vmClass = (superclass as ParameterizedType).actualTypeArguments[1]as Class<VM>
        viewModel= ViewModelProvider(this).get(vmClass);
    }

}